//
// Created by Administrator on 2022/7/8.
//
#include "Tree.cpp"
//交换左右子树 采用递归办法
void exchange(Tree root){
    TreeNode * temp;
    Tree p=root;
    if(p->leftChild!=NULL||p->rightChild!=NULL){
        temp=p->leftChild;
        p->leftChild=p->rightChild;
        p->rightChild=temp;
        exchange(root->leftChild);
        exchange(root->rightChild);
    }
}
void traverse(Tree root){
    if(root!=NULL){
        printf("%d",root->data);
        traverse(root->leftChild);
        traverse(root->rightChild);
    }
}
int main(){
    Tree tree = CreateTreeByFile("Day-623-1.txt");
    exchange(tree);
    traverse(tree);
}